package com.freedy.dataStructure.search;

import com.freedy.dataStructure.sort.Test;

import java.util.ArrayList;
import java.util.Arrays;


/**
 * @author Freedy
 * @date 2021/3/20 17:29
 */
public class SequenceSearch {
    public static void main(String[] args) {
        int[] arr ={1,9,11,-1,2,898,9,89,8,9,89,8,9};
        System.out.println(Arrays.toString(search(arr, 9)));
    }

    public static int[] search(int[] arr,int val){
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i < arr.length; i++) {
            if (arr[i]==val) list.add(i);
        }
        return list.stream().mapToInt(Integer::intValue).toArray();
    }



}
